@extends('common.admin_layout')
@section('title','编辑用户')
@section('content')
    <div class="app_content_div" id="app_content_div_301Index">
        <h3>编辑用户</h3>
    </div>
    <form class="form-horizontal">
        <div class="form-group">
            <label for="name" class="col-sm-2 control-label"><span style="color:red;">*</span>用户名</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="name" name="name" value="{{$oUser->name}}" readonly>
            </div>
        </div>

        <div class="form-group">
            <label for="email" class="col-sm-2 control-label"><span style="color:red;">*</span>邮箱</label>
            <div class="col-sm-10">
                <input type="email" class="form-control" id="email" name="email" value="{{$oUser->email}}" readonly >
            </div>
        </div>

        <div class="form-group">
            <label for="password" class="col-sm-2 control-label"><span style="color:red;">*</span>密码</label>
            <div class="col-sm-10">
                <input type="password" class="form-control" id="password" name="password" >
            </div>
        </div>

        <div class="form-group">
            <label for="password" class="col-sm-2 control-label"><span style="color:red;">*</span>确认密码</label>
            <div class="col-sm-10">
                <input type="password" class="form-control" id="password_confirmation" name="password_confirmation" >
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="button" onclick="update()" class="btn btn-default">确定</button>
            </div>
        </div>
    </form>
    <script>
        function update()
        {
            password=$("#password").val();
            password_confirmation=$("#password_confirmation").val();
            $.ajax({
                url:'/user/{{$oUser->id}}',
                type:'PUT',
                dataType:'json',
                data:{'password':password,'password_confirmation':password_confirmation,'_token':'{{csrf_token()}}'},
                success:function (data)
                {
                    if (data.success){
                        alert(data.msg);
                        location.href='/user';
                    }else {
                        alert(data.msg);
                    }
                },
                error:function (data)
                {

                }
            });

        }
    </script>
@endsection

